<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
	<%@ page isELIgnored="false" %>
	<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>  
<!DOCTYPE html>
<%
	String path = request.getContextPath();
%>
<html>
<head>

<link rel="stylesheet" type="text/css"
	href="<%=path%>/script/easyUI-1.4/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css"
	href="<%=path%>/script/easyUI-1.4/themes/icon.css">
<script type="text/javascript"
	src="<%=path%>/script/easyUI-1.4/jquery-3.2.1.min.js"></script>
<script type="text/javascript"
	src="<%=path%>/script/easyUI-1.4/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="<%=path%>/script/easyUI-1.4/locale/easyui-lang-zh_CN.js"></script>
	<style type="text/css">
		.displayA{
			color: grey
		}
		.displayA:active{
			color: grey
		}
	</style>
	
	<script type="text/javascript">

	$(function(){
		
		var isOther="${userId}";
		if(isOther!=null && isOther!=""){
			//说明访问的是别人的馆藏，需要把新增文章和相册的按钮隐藏
			$("#as").css("display","none")
			$("#btns").remove();
		}
		
		$('#fileTree').tree({    
		    url:'<%=path%>/guancangAction/getwenjianjiaData?userId=${userId}'   ,
		    onSelect: function(node){
		    	
		    	location.href="<%=path%>/guancangAction/guancangView?userId=${userId}&wenjianjia="+node.text;
		    	
			}
		});  
		
	})
	
	
	function show(id){
		$("#"+id+">#btns").css("display","inline");
		
	}
	
	function unShow(id){
		$("#"+id+">#btns").css("display","none");
	}
	
	function tuijian(articleId){
		
		var dataParm={"articleId":articleId};
		 $.ajax({
	            //几个参数需要注意一下
	                type: "POST",//方法类型
	                dataType: "json",//预期服务器返回的数据类型
	                url: "<%=path%>/guancangAction/tuijian",
	                data: dataParm,
	                success: function (result) {
	                    	
	                	if(result.errMsg!=null && result.errMsg!=""){
	                		$.messager.alert('提示',result.errMsg); 
	                		
	                	}else{
	                		
	                			$.messager.confirm('提示','操作成功',function(r){    
	                			  location.href="<%=path%>/views/user/main.jsp";
	                			});  
	                			
	                	}
	                },
	                error : function() {
	                    alert("系统异常！");
	                }
	            });
		
	}
	
function del(articleId){
		
		var dataParm={"articleId":articleId};
		 $.ajax({
	            //几个参数需要注意一下
	                type: "POST",//方法类型
	                dataType: "json",//预期服务器返回的数据类型
	                url: "<%=path%>/guancangAction/del",
	                data: dataParm,
	                success: function (result) {
	                    	
	                	if(result.errMsg!=null && result.errMsg!=""){
	                		$.messager.alert('提示',result.errMsg); 
	                		
	                	}else{
	                		
	                			$.messager.confirm('提示','删除成功',function(r){    
	                			  location.href="<%=path%>/views/user/main.jsp";
	                			});  
	                			
	                	}
	                    
	                    
	                },
	                error : function() {
	                    alert("系统异常！");
	                }
	            });
		
	}
		//查看某篇文章详细
		function desc(articleId){
			
			top.location.href="<%=path%>/guancangAction/articleDescView?articleId="+articleId;
		}
		
		
		function upt(articleId){
			location.href="<%=path%>/guancangAction/uptView?articleId="+articleId;
		}

	</script>
</head>




<body class="easyui-layout" >   
    
    <div data-options="region:'west'" style="width:300px;">
    	<ul id="fileTree" data-options="required:true" style="margin: 20px;"></ul> 
    </div>   
    <div data-options="region:'center'" >
    	<div style="padding: 20px;" id="as">
    		<a id="btn" href="<%=path%>/guancangAction/addArticleView" class="easyui-linkbutton" data-options="iconCls:'icon-article'" style="height: 50px;width: 100px">文章</a> 
    		<a id="btn" href="<%=path%>/guancangAction/addxiangceView" class="easyui-linkbutton" data-options="iconCls:'icon-music'" style="height: 50px;width: 100px;margin-left: 30px;">相册</a> 
    		<a id="btn" href="<%=path%>/guancangAction/addxiaoshuoView" class="easyui-linkbutton" data-options="iconCls:'icon-article'" style="height: 50px;width: 100px;margin-left: 30px;">小说</a> 
    	</div>
    	<hr>
    	<div>
    	
	<c:forEach items="${articleList}" var="article">
  		<div style="margin-left: 20px;" onmouseover="show(${article.id});" onmouseout="unShow(${article.id});" id="${article.id}">
  			<font size="2px" color="#030303" style="font-family:verdana;font-weight:bold" onclick="desc(${article.id});">${article.title}</font><br /><br />
                   <c:choose>
					   <c:when test="${fn:length(article.content)>50 }">    
					   		 <font size="3px;" color="grey">${fn:substring(article.content, 0, 50)}... </font> 
					   </c:when>
					   <c:otherwise>  
					   		<font size="3px;" color="grey">${fn:substring(article.content, 0, 50)} </font> 
					   </c:otherwise>
					</c:choose>
                   
  			<br /><br />
  			<font size="2px;" color="grey">阅：${article.yueduMount}</font>
  			<font size="2px;" color="grey">收：${article.shoucangMount}</font>
  			<font size="2px;" color="grey">评：${article.pinglunMount}</font>
  			<font size="2px;" color="grey">${article.quanxian}</font>
  			<font size="2px;" color="grey">${article.createTime}</font>
  		
  			<div id="btns" style="display: none;margin-left: 250px;">
  				<a class="displayA" href="#" onclick="del(${article.id});" style="">删除</a>
  				<a class="displayA" href="#" onclick="tuijian(${article.id});"">推荐到首页</a>
  				<a class="displayA" href="#" onclick="upt(${article.id})">修改</a>
  			</div>
  		</div>
  		
  		<hr>
  	</c:forEach>
    	
    	</div>
    </div>
    
</body>  

</html>